'''
Created on 25.08.2012

@author: Thomas Koch
'''

import sys



def search_track(query='', verb=False):
    print "searching for track '%s' ..." % query
    from pythonsolr import Solr
    con = Solr('http://localhost:8983/solr/mbtracks/')
    res = con.search(query, qt='mb_tracks')
    i = 0
    print "found %d" % len(res)
    for result in res:
        tname = result.get('t_name','?')
        aname = result.get('t_a_name','?')
        tuid = result.get('id',None)
        ttyp = result.get('t_type',None)
       
        print "%#d: id=%s\tname='%s'\tby: %s" % (i,tuid,tname,aname)
        if verb:
            print result
        i+=1

if __name__ == '__main__':
    print "enter text:"
    line = sys.stdin.readline()
    line = line.strip()

    search_track(line)
